$("#ensure").click(function () {
    var params = {
        name: $("#name").val(),
        user: $("#user").val(),
        follower: $("#follower").val(),
        xfollower: $("#xfollower").val(),
        belonger: $("#belonger").val(),
        xbelonger: $("#xbelonger").val(),
        sOneChannel: $("#sOneChannel").val(),
        sTwoChannel: $("#sTwoChannel").val(),
        sThrChannel: $("#sThrChannel").val(),
        oneChannel: $("#oneChannel").val(),
        twoChannel: $("#twoChannel").val(),
        thrChannel: $("#thrChannel").val(),
        remarks: $("#remarks").val(),
        outpatientName: $("#outpatientNameValue").val(),
        reservationsId: $("#reservationsId").val(),
        status: $("#status").val(),
        customerName: $("#customerName").val(),
        customerPhone: $("#customerPhone").val(),
        num: $("#num").val()
    };
    if ($("#oneChannel").val() == null || $("#oneChannel").val() == "请选择") {
        alert("请选择一级渠道！");
        return;
    }
    if ($("#twoChannel").val() == null || $("#twoChannel").val() == "请选择") {
        alert("请选择二级渠道！");
        return;
    }
    if ($("#thrChannel").val() == null || $("#thrChannel").val() == "请选择") {
        alert("请选择三级渠道！");
        return;
    }
    if ($("#avatarPreId").children().length <= 0) {
        alert("请上传图片！");
        return;
    }
    if ($("#remarks").val() == "" || $("#remarks").val() == null) {
        alert("请输入备注！");
        return;
    }
    $.ajax({
        url: Feng.ctxPath + "/customer/update_channel", type: "post", data: params, success: function (data) {
            Feng.success('操作成功!');
            $("#cancel").click();
        }, error: function (data) {
            alert('没有权限，请联系管理员!');
        }
    });
});

$("#cancel").click(function () {
    parent.layer.close(parent.layer.getFrameIndex(window.name));
});

$(document).on('click', '.cp_img_delete', function () {
    var that = this;
    var id = $(that).parent().attr("id");
    $.ajax({
        url: Feng.ctxPath + "/customer/delteProcessCancel",
        type: "post",
        data: {"id": id},
        success: function (data) {
            $(that).parent().remove();
            Feng.success("删除成功！");
        },
        error: function (data) {
            alert("删除失败！");
        }
    });
});

var avatarUp = "";

function iconTypeChange() {
    avatarUp = new $IconUpload("avatar");
    avatarUp.initIcon();
};

$(function () {
    iconTypeChange();
});